﻿@{
    ViewBag.Title = "3单位冲压件成品库收发情况统计";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<script>
    var moduleId = $.request("moduleId");
    var tempdata = 0;
    $(function () {
        initControl();
        gridList1();
        tempdata = 1;
    })
    function initControl() {
        $('select').bindSelect();
        $("#ZSJ_B1_GH_SI").bindSelect({
            url: "/BaseData/ZSJ_B1_GH_SI/GetGridJson",
            id: "UnitID",
            text: "UnitNOShortName"
        });
        //显示台账日期
        var keyValue = $.request("keyValue");
        $.ajax({
            url: "/WareHouse/EnterWareHouse/GetInfoDocumentNum",
            data: { keyValue: keyValue },
            dataType: "json",
            async: false,
            success: function (data) {
                $("#form1").formSerialize(data);
                $("#txt_FAccountDate").val(data);
                if (data == currentDate.format("yyyyMM")) {
                    tempdata = 1;
                }
                else { tempdata = 3; }
            }
        });
        //零件分类
        $("#txt_FProductionTypeName").bindSelect({//FClassNO ='01'
            url: "/VBaseData/V_BUS_SJ_Dictionary/GetSJ_DictionaryEntity",
            id: "UseUnit",
            text: "FTypeName",
        });
        //生产单位
        $("#txt_FHappenComNO").bindSelect({
            url: "/BaseData/ZSJ_B1_GH_SI/GetGridJson?isProduct=0",
            id: "UnitNO",
            text: "UnitNOShortName"
        });
        //供货单位
        $("#txt_FProCompanyName").bindSelect({
            url: "/BaseData/ZSJ_B1_GH_SI/GetGridJson?isProduct=1",
            id: "UnitNO",
            text: "UnitNOShortName"
        });
        $('.category').on("click", function () {
            var aa = $("input[type='radio'].category:checked").val();
            if (aa == '生产单位') {
                gridList1();
                tempdata = 1;
            }
            else if (aa == '销售单位') {
                gridList2();
                tempdata = 2;
            }
            else if (aa == '生产零件') {
                gridList3();
                tempdata = 3;
            }
            else if (aa == '销售零件') {
                gridList4();
                tempdata = 4;
            }
        });
    }
    function gridList1() {
        $("#grid1").show();
        $("#grid2").hide();
        $("#grid3").hide();
        $("#grid4").hide();
        var $gridList = $("#gridList1");
        $gridList.dataGridForJson({
            url: "/VBaseData/V_CPK_A3_BB_StoProStockCata_DWCR/GetGridJson?Ftype=1",
            height: $(window).height() - 120,
            colModel: [
                { label: '生产单位', name: 'FHappenComNO', width: 300, align: 'left', sortable: false },
                { label: '生产单位名称', name: 'FHappenComName', width: 380, align: 'left', sortable: false },
                { label: '本月数量', name: 'BYSL', width: 180, align: 'right', sortable: false },
                { label: '本月计划金额', name: 'BYJHJE', width: 180, align: 'right', sortable: false },
                { label: '本月结算金额', name: 'BYJSJE', width: 240, align: 'right', sortable: false },
            ],
            pager: "#gridPager1",
            sortname: 'FHappenComNO asc',
            viewrecords: true,
            onSelectRow: function (rowId) {
                rowData = $gridList.jqGrid('getRowData', rowId);
                index = rowId;
                $.each(rowData, function (key, value) {
                    $("#txt" + key).val(value);
                });
            }
        });
    }
    function gridList2() {
        $("#grid1").hide();
        $("#grid2").show();
        $("#grid3").hide();
        $("#grid4").hide();
        var $gridList = $("#gridList2");
        $gridList.dataGridForJson({
            url: "/VBaseData/V_CPK_A2_BB_StoProStockCata_LJCR/GetGridJson?Ftype=1",
            height: $(window).height() - 120,
            colModel: [
                { label: '生产单位', name: 'FHappenComNO', width: 80, align: 'left', sortable: false },
                { label: '生产单位名称', name: 'FHappenComName', width: 180, align: 'left', sortable: false },
                { label: '零件编号', name: 'FProductionNO', width: 120, align: 'left', sortable: false },
                { label: '零件名称', name: 'FProductionName', width: 180, align: 'left', sortable: false },
                { label: '本月数量', name: 'BYSL', width: 60, align: 'right', sortable: false },

                { label: '计划单单价', name: 'JHDJ', width: 80, align: 'right', sortable: false },
                { label: '本月计划金额', name: 'BYJHJE', width: 80, align: 'right', sortable: false },
                { label: '计算单价', name: 'JSDJ', width: 60, align: 'right', sortable: false },
                { label: '本月结算金额', name: 'BYJSJE', width: 90, align: 'right', sortable: false },
                { label: '供货单位编码', name: 'FProCompanyNO', width: 100, align: 'left', sortable: false },

                { label: '供货单位名称', name: 'FProCompanyName', width: 180, align: 'left', sortable: false },
                { label: '零件分类', name: 'FProductionTypeName', width: 80, align: 'left', sortable: false },
            ],
            pager: "#gridPager2",
            sortname: 'FHappenComNO asc',
            viewrecords: true,
            onSelectRow: function (rowId) {
                rowData = $gridList.jqGrid('getRowData', rowId);
                index = rowId;
                $.each(rowData, function (key, value) {
                    $("#txt" + key).val(value);
                });
            }
        });
    }
    function gridList3() {
        $("#grid1").hide();
        $("#grid2").hide();
        $("#grid3").show();
        $("#grid4").hide();
        var $gridList = $("#gridList3");
        $gridList.dataGridForJson({
            url: "/VBaseData/V_CPK_A3_BB_StoProStockCata_DWCR/GetGridJson?Ftype=2",
            height: $(window).height() - 120,
            colModel: [
                { label: '销售单位', name: 'FHappenComNO', width: 300, align: 'left', sortable: false },
                { label: '销售单位名称', name: 'FHappenComName', width: 380, align: 'left', sortable: false },
                { label: '本月数量', name: 'BYSL', width: 180, align: 'right', sortable: false },
                { label: '本月计划金额', name: 'BYJHJE', width: 180, align: 'right', sortable: false },
                { label: '本月结算金额', name: 'BYJSJE', width: 240, align: 'right', sortable: false },
            ],
            pager: "#gridPager3",
            sortname: 'FHappenComNO asc',
            viewrecords: true,
            onSelectRow: function (rowId) {
                rowData = $gridList.jqGrid('getRowData', rowId);
                index = rowId;
                $.each(rowData, function (key, value) {
                    $("#txt" + key).val(value);
                });
            }
        });
    }
    function gridList4() {
        $("#grid1").hide();
        $("#grid2").hide();
        $("#grid3").hide();
        $("#grid4").show();
        var $gridList = $("#gridList4");
        $gridList.dataGrid({
            url: "/VBaseData/V_CPK_A2_BB_StoProStockCata_LJCR/GetGridJson?Ftype=2",
            height: $(window).height() - 120,
            colModel: [
                { label: '销售单位', name: 'FHappenComNO', width: 80, align: 'left', sortable: false },
                { label: '销售单位名称', name: 'FHappenComName', width: 180, align: 'left', sortable: false },
                { label: '零件编号', name: 'FProductionNO', width: 120, align: 'left', sortable: false },
                { label: '零件名称', name: 'FProductionName', width: 180, align: 'left', sortable: false },
                { label: '本月数量', name: 'BYSL', width: 60, align: 'right', sortable: false },

                { label: '计划单单价', name: 'JHDJ', width: 80, align: 'right', sortable: false },
                { label: '本月计划金额', name: 'BYJHJE', width: 80, align: 'right', sortable: false },
                { label: '计算单价', name: 'JSDJ', width: 60, align: 'right', sortable: false },
                { label: '本月结算金额', name: 'BYJSJE', width: 90, align: 'right', sortable: false },
                { label: '供货单位编码', name: 'FProCompanyNO', width: 100, align: 'left', sortable: false },

                { label: '供货单位名称', name: 'FProCompanyName', width: 180, align: 'left', sortable: false },
                { label: '零件分类', name: 'FProductionTypeName', width: 80, align: 'left', sortable: false },
            ],
            pager: "#gridPager4",
            sortname: 'FHappenComNO asc',
            viewrecords: true,
            onSelectRow: function (rowId) {
                rowData = $gridList.jqGrid('getRowData', rowId);
                index = rowId;
                $.each(rowData, function (key, value) {
                    $("#txt" + key).val(value);
                });
            }
        });
    }
    function btn_Excel() {
        $.detailOpen({
            id: "Detail",
            title: "",
            url: "/WareHouse/Export/WareHouseNoticeExcel"
        });
    }
    function btn_Print() {
        $.detailOpen({
            id: "Detail",
            title: "",
            url: "/WareHouse/Print/WareHouseNoticePrint"
        });
    }
    function btn_Search() {
        //alert($tr.find('input[name="txt_FProCompanyNO"]').val());
        if (tempdata == 1) {
            gridListSearch($("#gridList1"))
        }
        else if (tempdata == 2) {
            gridListSearch($("#gridList2"))
        }
        else if (tempdata == 3) {
            gridListSearch($("#gridList3"))
        }
        else if (tempdata == 4) {
            gridListSearch($("#gridList4"))
        }
    }
    function gridListSearch(obj) {
        obj.jqGrid('setGridParam', {
            postData: {//台账日期faccountDate,零件编号fproductionNo, 零件名称fproductionName,供货单位 fproCompanyNO,零件分类fproductionTypeName
                faccountDate: $("#txt_FAccountDate").val(), fproductionNo: $("#txt_FProductionNO").val(),
                fproductionName: $("#txt_FProductionName").val(), fproCompanyNO: $("#txt_FProCompanyNO").val(), fproductionTypeName: $("#txt_FProductionTypeName").val()
            },
        }).trigger('reloadGrid');
    }
</script>
<body>
    <div id="layout" style="height: 100%; width: 100%;">
        <form id="form1">
            <div style="padding: 12px 0 5px 0; padding-left:15px; border-bottom:1px solid #ccc;margin-top:-9px" class="line-table input-width-185">
                <div class="updowninput btn-group" style="margin-top:0px;margin-right:20px;">
                    <input id="radio11" class="category" name="category" value="生产单位" checked="checked" type="radio"><label for="radio11" class="suffix">生产单位</label>
                    <input id="radio12" class="category" name="category" value="销售单位" type="radio"><label for="radio2" class="suffix">销售单位</label><br />
                    <input id="radio13" class="category" name="category" value="生产零件" type="radio"><label for="radio3" class="suffix">生产零件</label>
                    <input id="radio14" class="category" name="category" value="销售零件" type="radio"><label for="radio4" class="suffix">销售零件</label>
                </div>
                <div class="btn-group">
                    生产单位<br />
                    <select id="txt_FHappenComNO" name="" class="form-control">
                        <option value="">==请选择==</option>
                    </select>
                    &nbsp;
                </div>
                <div class="btn-group">
                    零件编号<br />
                    <input id="txt_FProductionName" name="" placeholder="" type="text" class="form-control required  input-width-105" />
                    &nbsp;
                </div>
                <div class="btn-group">
                    供货单位<br />
                    <select id="txt_FProCompanyName" name="" class="form-control">
                        <option value="">==请选择==</option>
                    </select>
                    &nbsp;
                </div>
                <div class="btn-group">
                    零件分类<br />
                    <select id="txt_FProductionTypeName" name="F_DutyId" class="form-control">
                        <option value="">==请选择==</option>
                    </select>
                    &nbsp;
                </div>
                <div class="btn-group">
                    台账日期<br />
                    <input id="txt_FAccountDate" name="" placeholder="" type="text" class="form-control required input-width-80" onfocus="WdatePicker({ dateFmt: 'yyyyMM', isShowToday: false, isShowClear: false });" />
                    &nbsp;
                </div>
                <div class="btn-group" style="margin-top:12px;margin-left:10px;">
                    &nbsp;
                    <a id="" class="btn btn-primary center-block" onclick="btn_Search()"><span class="glyphicon glyphicon-search"></span>  &nbsp; 查询</a>
                </div>

                <div class="btn-group" style="float:right;margin-top:12px;">
                    <a class="btn btn-primary center-block" onclick="$.reload()">  <span class="glyphicon glyphicon-refresh"> </span>&nbsp刷新</a>
                    <a class="btn btn-primary center-block" onclick="          ">  <span class="glyphicon glyphicon-refresh"> </span>&nbsp计算</a>
                    <a class="btn btn-primary center-block" onclick="btn_Excel()"> <span class="glyphicon glyphicon-download"></span>&nbsp导出</a>
                    <a class="btn btn-primary center-block" onclick="btn_Print()"> <span class="glyphicon glyphicon-print">   </span>&nbsp打印</a>
                </div>
            </div>
        </form>
        <div id="grid1">
            <table id="gridList1"></table>
            <div id="gridPager1"></div>
        </div>
        <div id="grid2">
            <table id="gridList2"></table>
            <div id="gridPager2"></div>
        </div>
        <div id="grid3">
            <table id="gridList3"></table>
            <div id="gridPager3"></div>
        </div>
        <div id="grid4">
            <table id="gridList4"></table>
            <div id="gridPager4"></div>
        </div>
    </div>
</body>


